package com.zzh.takeoutapp.service;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.support.v4.app.ActivityCompat;
import android.telephony.TelephonyManager;
import android.util.Log;

import com.zzh.takeoutapp.config.Constants;
import com.zzh.takeoutapp.config.UrlConfig;
import com.zzh.takeoutapp.utils.SPUtils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zzh
 * @Name:
 * @Description:
 * @date
 * @time
 * @copyright
 */
public class ServiceUrl {
    // String ANDROID_ID = Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID);

    public static String getDeviceId(Context context) {
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            return null;
        }
        String DEVICE_ID = tm.getDeviceId();
        return DEVICE_ID;
    }

    /**
     * 注册
     *
     * @param context
     * @param mobile
     * @param passwd
     * @param type
     */
    public static void RegisterService(Context context,
                                       String mobile,
                                       String passwd,
                                       String sms_code,
                                       String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/passport/signup");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("mobile", mobile);
            jsonObject.put("passwd", passwd);
            jsonObject.put("sms_code", sms_code);
            jsonObject.put("pmid", "");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }


    /**
     * 客户端用户登录
     *
     * @param context
     * @param mobile
     * @param passwd
     * @param register_id
     * @param type
     */
    public static void LoginService(Context context,
                                    String mobile,
                                    String passwd,
                                    String register_id,
                                    String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/passport/login");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("mobile", mobile);
            jsonObject.put("passwd", passwd);
            jsonObject.put("register_id", register_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }


    /**
     * 发送验证码
     *
     * @param context
     * @param mobile
     * @param is_register
     * @param type
     */
    public static void sendsmsServiceUrl(Context context,
                                         String mobile,
                                         String is_register,
                                         String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("API", "client/member/passport/sendsms");
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        addMap.put("CLIENT_VER", "CUSTOM");
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("mobile", mobile);
            jsonObject.put("register_id", is_register);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 首页数据
     *
     * @param context
     * @param type
     */

    public static void HomeServiceUrl(Context context, String lat, String lng, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("API", "client/v3/waimai/index");
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("LAT", lat);
        addMap.put("LNG", lng);
        addMap.put("CITY_ID", "");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        addMap.put("CLIENT_VER", "CUSTOM");
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("page", 1);
            jsonObject.put("lat", lat);
            jsonObject.put("lng", lng);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 商家筛选列表页
     *
     * @param context
     * @param page
     * @param type
     */

    public static void FiltrateServiceUrl(Context context,
                                          String lat,
                                          String lng,
                                          String youhui_filter,
                                          String feature_filter,
                                          String pei_filter,
                                          String cate_id,
                                          String order,
                                          int page, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/shop/shoplist");
        addMap.put("LAT", lat);
        addMap.put("LNG", lng);
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("youhui_filter", youhui_filter);
            jsonObject.put("feature_filter", feature_filter);
            jsonObject.put("pei_filter", pei_filter);
            jsonObject.put("cate_id", cate_id);
            jsonObject.put("order", order);
            jsonObject.put("page", page);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        Log.e("jsonObject", addMap.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 客户端商家详情页
     *
     * @param context
     * @param type
     */
    public static void ShopDetailServiceUrl(Context context, String shop_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/shop/detail");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("CITY_ID", "0551");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("shop_id", shop_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 客户端商家评论页面
     *
     * @param context
     * @param type
     */
    public static void CommentsServiceUrl(Context context, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/shop/comments");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("CITY_ID", "0551");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("type", 0);
            jsonObject.put("shop_id", "182");
            jsonObject.put("page", 1);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户提交订单接口
     *
     * @param context
     * @param type
     * @param products
     */
    public static void OrderServiceUrl(Context context, String type, String shop_id, String products) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/order");
        addMap.put("LAT", SPUtils.getString(context, Constants.ALL_LATITUDE, ""));
        addMap.put("LNG", SPUtils.getString(context, Constants.ALL_LONGITUDE, ""));
        addMap.put("CITY_ID", "0551");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("products", products);
            jsonObject.put("shop_id", shop_id);
            jsonObject.put("lat", SPUtils.getString(context, Constants.ALL_LATITUDE, ""));
            jsonObject.put("lng", SPUtils.getString(context, Constants.ALL_LONGITUDE, ""));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /***
     * 用户创建订单接口
     * @param context
     * @param online_pay
     * @param shop_id
     * @param product_price
     * @param pei_time
     * @param pei_type
     * @param coupon_id
     * @param hongbao_id
     * @param addr_id
     * @param total_price
     * @param intro
     * @param products
     * @param type
     */
    public static void CreateOrderServiceUrl(Context context, String online_pay, String shop_id,
                                             String product_price, String pei_time, String pei_type,
                                             String coupon_id, String hongbao_id, String addr_id,
                                             String total_price,
                                             String intro,
                                             String products,
                                             String lat,
                                             String lng,
                                             String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/create");
        addMap.put("LAT", lat);
        addMap.put("LNG", lng);
        addMap.put("CITY_ID", "0551");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("online_pay", online_pay);
            jsonObject.put("shop_id", shop_id);
            jsonObject.put("product_price", product_price);
            jsonObject.put("pei_time", pei_time);
            jsonObject.put("pei_type", pei_type);
            jsonObject.put("coupon_id", coupon_id);
            jsonObject.put("hongbao_id", hongbao_id);
            jsonObject.put("addr_id", addr_id);
            jsonObject.put("products", products);
            jsonObject.put("total_price", total_price);
            jsonObject.put("intro", intro);
            jsonObject.put("lat", lat);
            jsonObject.put("lng", lng);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        Log.e("jsonObject", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /***
     *
     * @param context
     * @param type
     */
    public static void AddressServiceUrl(Context context, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/addr/index");
        addMap.put("CITY_ID", "0551");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("page", 1);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户收货地址添加接口
     *
     * @param context
     * @param lng
     * @param addr
     * @param house
     * @param typeNum
     * @param contact
     * @param lat
     * @param mobile
     * @param type
     */
    public static void AddrCreateServiceUrl(Context context, String api, String addr_id, String lng, String addr
            , String house, String typeNum, String contact, String lat, String mobile, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", api);
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("addr_id", addr_id);
            jsonObject.put("lng", lng);
            jsonObject.put("addr", addr);
            jsonObject.put("house", house);
            jsonObject.put("typeNum", typeNum);
            jsonObject.put("contact", contact);
            jsonObject.put("lat", lat);
            jsonObject.put("mobile", mobile);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    public static void AddrCreateServiceUrl(Context context, String api, String lng, String addr
            , String house, String typeNum, String contact, String lat, String mobile, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", api);
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("lng", lng);
            jsonObject.put("addr", addr);
            jsonObject.put("house", house);
            jsonObject.put("typeNum", typeNum);
            jsonObject.put("contact", contact);
            jsonObject.put("lat", lat);
            jsonObject.put("mobile", mobile);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户收货地址删除接口
     *
     * @param context
     * @param addr_id
     * @param type
     */
    public static void AddrDeleteServiceUrl(Context context, String addr_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/addr/delete");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("addr_id", addr_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 订单列表数据
     *
     * @param context
     * @param type
     */

    public static void OrderIndexService(Context context, int page, String pay_status, String type) {

        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/index");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        //addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        addMap.put("TOKEN", "86-KTB12B1BAADFCB2BDA6E08617D3B9DF46D");
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("pay_status", pay_status);
            jsonObject.put("page", page);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);


    }


    /**
     * 客户端商家详细描述
     *
     * @param context
     * @param shop_id
     * @param type
     */
    public static void MerchantService(Context context, String shop_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/shop/info");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("shop_id", shop_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 客户端用户订单详情
     *
     * @param context
     * @param order_id
     * @param type
     */
    public static void OrderDetailService(Context context, String order_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/detail");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户基本信息
     *
     * @param context
     * @param type
     */
    public static void UserInfoService(Context context, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/info");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户基本信息名称修改
     *
     * @param context
     * @param nickname
     * @param type
     */
    public static void UpdaTenameService(Context context, String nickname, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/updatename");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "3.9");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("nickname", nickname);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户基本信息头像修改
     *
     * @param context
     * @param nickname
     * @param file
     * @param type
     */
    public static void UpdaFaceService(Context context, String nickname, List<File> file, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/updateface");
        addMap.put("CITY_ID", "");
        addMap.put("CLIENT_VER", "3.9");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("nickname", nickname);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.postFile(context, UrlConfig.URL_ALL, addMap, file, type);
    }

    /**
     * 客户端商家筛选列表分类获取接口
     *
     * @param context
     * @param youhui_filter
     * @param feature_filter
     * @param pei_filter
     * @param cate_id
     * @param order
     * @param page
     * @param type
     */
    public static void CateIndexService(Context context,
                                        String youhui_filter,
                                        String feature_filter,
                                        String cate_id,
                                        String pei_filter,
                                        String order,
                                        int page, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/cate/index");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("youhui_filter", youhui_filter);
            jsonObject.put("feature_filter", feature_filter);
            jsonObject.put("pei_filter", pei_filter);
            jsonObject.put("cate_id", cate_id);
            jsonObject.put("order", order);
            jsonObject.put("page", page);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 客户端用户评论提交表单接口
     *
     * @param context
     * @param score
     * @param content
     * @param score_peisong
     * @param order_id
     * @param pei_time
     * @param info_id
     * @param type
     */
    public static void OrederCommentSercive(Context context,
                                            String score,
                                            String content,
                                            String score_peisong,
                                            String order_id,
                                            String pei_time,
                                            String info_id,
                                            String type) {

        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/comment");
        addMap.put("LAT", "24.78441");
        addMap.put("LNG", "115.027845");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("score", score);
            jsonObject.put("content", content);
            jsonObject.put("score_peisong", score_peisong);
            jsonObject.put("order_id", order_id);
            jsonObject.put("pei_time", pei_time);
            jsonObject.put("info", info_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }


    /**
     * 返回搜索条件
     *
     * @param context
     * @param type
     */
    public static void ConditionService(Context context,
                                        String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/cate/condition");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 获取个人收藏
     *
     * @param context
     * @param type
     */
    public static void LoadcollectSerVice(Context context,
                                          String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        addMap.put("API", "client/member/collect/items");
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("type", "waimai");
            jsonObject.put("lat", SPUtils.getString(context, Constants.ALL_LATITUDE, ""));
            jsonObject.put("lng", SPUtils.getString(context, Constants.ALL_LONGITUDE, ""));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 获取个人评论
     *
     * @param context
     * @param page
     * @param type
     */
    public static void CommentService(Context context, int page, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/comment/items");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("page", page);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 添加收藏
     *
     * @param context
     * @param waimai
     * @param can_id
     * @param type
     */
    public static void AddCollectSerVice(Context context, String waimai, String can_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/collect/add");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("type", waimai);
            jsonObject.put("can_id", can_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 取消收藏
     *
     * @param context
     * @param waimai
     * @param can_id
     * @param type
     */
    public static void CancelCollectSerVice(Context context, String waimai, String can_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/member/collect/cancel");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("type", waimai);
            jsonObject.put("can_id", can_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 客户端用户订单评论详情
     *
     * @param context
     * @param comment_id
     * @param type
     */
    public static void CommentDetailService(Context context, String comment_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/comment_detail");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("comment_id", comment_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 客户端用户评论提交表单接口
     *
     * @param context
     * @param score
     * @param content
     * @param score_peisong
     * @param order_id
     * @param pei_time
     * @param type
     */
    public static void CommentService(Context context,
                                      float score,
                                      String content,
                                      float score_peisong,
                                      String order_id,
                                      String pei_time,
                                      String info,
                                      List<File> fileList,
                                      String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/comment");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("score", score);
            jsonObject.put("content", content);
            jsonObject.put("score_peisong", score_peisong);
            jsonObject.put("order_id", order_id);
            jsonObject.put("pei_time", pei_time);
            jsonObject.put("info", info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        Log.e("evaluateItemAdapter", jsonObject.toString());
        PublicRequest.postFile(context, UrlConfig.URL_ALL, addMap, fileList, type);
    }

    /**
     * 用户取消订单
     *
     * @param context
     * @param order_id
     * @param type
     */
    public static void ChargeBackService(Context context, String order_id, String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/chargeback");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 选中配送地址返回订单信息
     *
     * @param context
     * @param order_id
     * @param products
     * @param is_ziti
     * @param online_pay
     * @param addr_id
     * @param hongbao_id
     * @param coupon_id
     * @param type
     */
    public static void PreinfoService(Context context,
                                      String order_id,
                                      String products,
                                      String is_ziti,
                                      String online_pay,
                                      String addr_id,
                                      String hongbao_id,
                                      String coupon_id,
                                      String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/preinfo");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("order_id", order_id);
            jsonObject.put("products", products);
            jsonObject.put("is_ziti", is_ziti);
            jsonObject.put("online_pay", online_pay);
            jsonObject.put("addr_id", addr_id);
            jsonObject.put("hongbao_id", hongbao_id);
            jsonObject.put("coupon_id", coupon_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }

    /**
     * 用户催单
     *
     * @param context
     * @param order_id
     * @param type
     */
    public static void remindService(Context context,
                                     String order_id,
                                     String type) {
        Map<String, String> addMap = new HashMap<>();
        addMap.put("CLIENT_API", "CUSTOM");
        addMap.put("CLIENT_OS", "ANDROID");
        addMap.put("REGISTER_ID", getDeviceId(context));
        addMap.put("API", "client/v3/waimai/order/remind");
        addMap.put("TOKEN", SPUtils.getString(context, Constants.TOKEN, ""));
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        addMap.put("data", jsonObject.toString());
        PublicRequest.doPostRequest(context, UrlConfig.URL_ALL, addMap, type);
    }


}
